package relation;

import cn.moukou.dictator.ServerApplication;
import cn.moukou.dictator.dao.node.KVNodeDAO;
import cn.moukou.dictator.dao.relation.KVNODE_RELATION_DAO;
import cn.moukou.dictator.dao.relation.STUDENT_CLASS_DAO;
import cn.moukou.dictator.dao.relation.STUDENT_COMPETITION_DAO;
import cn.moukou.dictator.dao.relation.STUDENT_TEACHER_DAO;
import cn.moukou.dictator.pojo.node.KVNode;
import cn.moukou.dictator.pojo.relation.KVNODE_RELATION;
import cn.moukou.dictator.pojo.relation.STUDENT_CLASS;
import cn.moukou.dictator.pojo.relation.STUDENT_COMPETITION;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;

import java.util.ArrayList;
import java.util.List;

@SpringBootTest(classes = ServerApplication.class)
public class STUDENT_COMPETITION_TEST {
    @Autowired
    STUDENT_COMPETITION_DAO relationDao;
    @Autowired
    KVNODE_RELATION_DAO kvRelationDao;
    @Autowired
    KVNodeDAO kvDao;

    @Test
    public void addRelation() {
        List<String> namaList = new ArrayList<>();
        namaList.add("第十八届全国创新英语大赛");
        namaList.add("新加坡中国演讲比赛新加坡总决赛赛区");

        KVNode start = kvDao.customFindByStudentName("冯璐");
        for (int i = 0; i < namaList.size(); ++i) {
            KVNode end = kvDao.customFindByCompetitionName(namaList.get(i));
            STUDENT_COMPETITION relation = new STUDENT_COMPETITION();
            relation.setStartNode(start);
            relation.setEndNode(end);
            relationDao.save(relation);
        }
//        KVNode end = kvDao.customFindByCompetitionName("山东省第五届高中力学邀请赛");
//        System.out.println(end);

    }

    @Test
    public void addKVNODE_RELATION() {
        Iterable<STUDENT_COMPETITION> it = relationDao.findAll();
        for (STUDENT_COMPETITION st_com : it) {
            System.out.println(st_com);
            KVNODE_RELATION kvRelation = new KVNODE_RELATION();
            kvRelation.setStartNode(st_com.getStartNode());
            kvRelation.setEndNode(st_com.getEndNode());
            kvRelation.setRelationType("student_competition");
            kvRelation.setRelationLabel("st_com");
            kvRelationDao.save(kvRelation);
        }
    }
}
